<?php
$dis_id=3;
include("../../inc/conn.inc");
include("../islogin2.php");


if($_POST['act_xg']){
	    $c_rs=@mysql_query("select * from city where id='$_POST[c_provinces]' and city_id=0");
		$c_row=@mysql_fetch_array($c_rs);
		$c_rs2=@mysql_query("select * from city where id='$_POST[c_city]' and city_id>0");
		$c_row2=@mysql_fetch_array($c_rs2);
		$c_rs3=@mysql_query("select * from city where id='$_POST[c_diqu]' and city_id>0");
		$c_row3=@mysql_fetch_array($c_rs3);
		$c_provinces=($_POST[c_provinces])?$_POST[c_provinces]:0;
		$c_city=($_POST[c_city])?$_POST[c_city]:0;
		$c_diqu=($_POST[c_diqu])?$_POST[c_diqu]:0;
	    
		
		$f_zhouqi=$_POST[f_zhouqi1]."@".$_POST[f_zhouqi2];
		$f_lilv=$_POST[f_lilv1]."%".$_POST[f_lilv2];
		
        @mysql_query("update jd_fangdai set member_id='".$_COOKIE['user_id']."',fd_title='$_POST[f_title]',fd_jiner='$_POST[f_jiner]',fd_duixiang='$_POST[f_duixiang]',fd_zhouqi='$f_zhouqi',fd_shenpi='$_POST[f_shenpi]',fd_lilv='$f_lilv',fd_pro_id='$c_provinces',fd_pro='$c_row[city_name]',fd_city_id='$c_city',fd_city='$c_row2[city_name]',fd_diqu_id='$c_diqu',fd_diqu='$c_row3[city_name]',fd_danbao='$_POST[f_danbao]',fd_shuoming='$_POST[f_shuoming]',fd_cl='0' where id='".$_POST['iid']."'");
	    
	   echo "<script>alert('编辑成功');location='".$_POST['urls']."';</script>";	 

}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员中心-三帝贸易网</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript" src="../js/left.js" charset="gb2312"></script>
<script type="text/javascript" src="/js/city.js" charset="gb2312"></script>
<body>
<div id="mian">
<?php include("../inc/top.php");?>
<div class="top1"><span>您当前位置：<a href="../index.php" class="dh">会员助手</a> &gt;&gt; 供应信息 &gt;&gt; 编辑放贷</span></div>
<div class="left">
<?php include("../inc/left.php");?>
</div>
<div class="right">
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
   <TR>
     <TD height="40" bgcolor="#EFF6FF" style="font-size:18px;font-weight:bold;padding-left:8px;">编辑放贷</TD>
   </TR>
</TABLE>
<br>
<?php
$rs=mysql_query("select * from jd_fangdai where id='".$_GET['xg_id']."' and member_id='".$_COOKIE['user_id']."'");
$row=mysql_fetch_array($rs);
if(!$row['id']){
echo "<script>alert('非法提交');location='index.php'</script>";
}
?>
<TABLE cellSpacing=1 cellPadding=5 width="100%" bgColor=#c1dcf5 border=0>
  <TBODY>
  <FORM name="form1" onSubmit="return checkform()" action="" method="post">
  <TR>
    <TD align=middle width="17%" bgColor=#eff6ff>放贷标题：<FONT color=#ff0000>*</FONT></TD>
    <TD style="PADDING-LEFT: 4px" width="83%" bgColor=#f9f9f9><INPUT id="f_title" maxLength="250" size="50" name="f_title" value="<?=$row[fd_title]?>"></TD>
  </TR>
  <TR>
    <TD align=middle bgColor=#eff6ff>贷款金额：<FONT color=#ff0000>*</FONT></TD>
    <TD style="PADDING-LEFT: 4px;" bgColor=#f9f9f9><select name="f_jiner">
	  <option value="">选择贷款金额</option>
	  <option value="50" <?php if($row[fd_jiner]=="50"){echo "selected";}?>>50万以下</option>
	  <option value="50-100" <?php if($row[fd_jiner]=="50-100"){echo "selected";}?>>50-100万</option>
	  <option value="100-200" <?php if($row[fd_jiner]=="100-200"){echo "selected";}?>>100-200万</option>
	  <option value="200-400" <?php if($row[fd_jiner]=="200-400"){echo "selected";}?>>200-400万</option>
	  <option value="400-600" <?php if($row[fd_jiner]=="400-600"){echo "selected";}?>>400-600万</option>
	  <option value="600-800" <?php if($row[fd_jiner]=="600-800"){echo "selected";}?>>600-800万</option>
	  <option value="800-1000" <?php if($row[fd_jiner]=="800-1000"){echo "selected";}?>>800-1000万</option>
	  <option value="1000" <?php if($row[fd_jiner]=="1000"){echo "selected";}?>>1000万以上</option>
	</select></TD>
  </TR>
  <TR>
    <TD align=middle bgColor=#eff6ff>贷款对象：<FONT color=#ff0000>*</FONT></TD>
    <TD style="PADDING-LEFT: 4px" bgColor=#f9f9f9>
	<select id="f_duixiang" name="f_duixiang">
	  <option value="">选择贷款对象</option>
      <option value="个人" <?php if($row[fd_duixiang]=="个人"){echo "selected";}?>>个人</option>
      <option value="企业" <?php if($row[fd_duixiang]=="企业"){echo "selected";}?>>企业</option>
      <option value="个人及企业" <?php if($row[fd_duixiang]=="个人及企业"){echo "selected";}?>>个人及企业</option>
     </select></TD>
  </TR>
  <?php $fd_zhouqi=explode("@",$row[fd_zhouqi]);?>
  <TR>
    <TD align=middle bgColor=#eff6ff>贷款周期：<FONT color=#ff0000>*</FONT></TD>
    <TD style="PADDING-LEFT:4px;" bgColor=#f9f9f9><input name="f_zhouqi1" type="text" id="f_zhouqi1" value="<?=$fd_zhouqi[0]?>" size="5" maxlength="20" />
	 <select id="f_zhouqi2" name="f_zhouqi2">
        <option value="年" <?php if($fd_zhouqi[0]=="年"){echo "selected";}?>>年</option>
        <option value="月" <?php if($fd_zhouqi[1]=="月"){echo "selected";}?>>月</option>
      </select></TD>
  </TR>
  <?php $fd_lilv=explode("%",$row[fd_lilv]);?>
  <TR>
    <TD align=middle bgColor=#eff6ff>贷款利率：<FONT  color=#ff0000>*</FONT></TD>
    <TD style="PADDING-LEFT: 4px" bgColor=#f9f9f9><input name="f_lilv1" type="text" id="f_lilv1" value="<?=$fd_lilv[0]?>" size="5" maxlength="10" /> 
    %
    <select id="f_lilv2" name="f_lilv2">
        <option value="年" <?php if($fd_lilv[0]=="年"){echo "selected";}?>>年</option>
        <option value="月" <?php if($fd_lilv[1]=="月"){echo "selected";}?>>月</option>
    </select></TD>
  </TR>
  <TR>
    <TD align=middle bgColor=#eff6ff>审批时间：<FONT color=#ff0000>*</FONT></TD>
    <TD style="PADDING-LEFT: 4px" bgColor=#f9f9f9><INPUT name="f_shenpi" id="f_shenpi" value="<?=$row[fd_shenpi]?>" size="10" maxlength="20"> 
    天</TD>
  </TR>
  <TR>
    <TD align=middle bgColor=#eff6ff>货款地区：<FONT color=#ff0000>*</FONT></TD>
    <TD style="PADDING-LEFT: 4px" bgColor=#f9f9f9><select name="c_provinces" onChange="changecity(document.form1.c_provinces.options[document.form1.c_provinces.selectedIndex].value)">
<option value="">--选择省份--</option>    
<?    
$rs01=@mysql_query("select * from city where city_id=0 order by order_name asc");    
while($res=@mysql_fetch_array($rs01)){    
?>    
<option value="<?=$res['id']?>" <?php if($row[fd_pro_id]==$res[id]){echo "selected";}?>><?=$res['city_name']?></option> 
<? } ?>    
</select>     
<select name="c_city" id="c_city"  onChange="changecity2(document.form1.c_city.options[document.form1.c_city.selectedIndex].value)">                    
  <option value="">--选择城市--</option>
  			<?php
			$rs2=mysql_query("select * from city where city_id='$row[fd_pro_id]' order by id asc");
			while($row2=mysql_fetch_array($rs2)){
			?>
			<option value="<?=$row2['id']?>" <?php if($row[fd_city_id]==$row2[id]){echo "selected";}?>><?=$row2['city_name']?></option>
			<?php
			}?>  
</select>
	   <select name="c_diqu" id="c_diqu">
            <option value="">--选择地区--</option>
			<?php
			$rs3=mysql_query("select * from city where city_id='$row[fd_city_id]' order by id asc");
			while($row3=mysql_fetch_array($rs3)){
			?>
			<option value="<?=$row3['id']?>" <?php if($row[fd_diqu_id]==$row3[id]){echo "selected";}?>><?=$row3[city_name]?></option>
			<?php
			}?> 
       </select></TD>
  </TR>
  <TR>
    <TD align=middle bgColor=#eff6ff>担保方式：<FONT color=#ff0000>*</FONT></TD>
    <TD style="PADDING-LEFT: 4px" bgColor=#f9f9f9><INPUT id="f_danbao" maxLength="200" size="70" name="f_danbao" value="<?=$row[fd_danbao]?>"></TD>
  </TR>
  <TR>
    <TD align=middle bgColor=#eff6ff>贷款说明：<FONT color=#ff0000>*</FONT></TD>
    <TD style="PADDING-LEFT: 4px" bgColor=#f9f9f9><textarea id="f_shuoming" name="f_shuoming" cols="70" rows="20"><?=$row[fd_shuoming]?></textarea></TD>
  </TR>
  <TR>
    <TD align=middle bgColor=#eff6ff>&nbsp;</TD>
	<input type="hidden" name="act_xg" value="ok">
	<input type="hidden" name="iid" value="<?=$row['id']?>">
	<input type="hidden" name="urls" value="<?=$_SERVER['HTTP_REFERER']?>">
    <TD style="PADDING-LEFT: 4px" bgColor=#f9f9f9><input name="submit" type="submit" value="提交"></TD>
  </TR>
  </FORM>
</TABLE>
</div>
<div class="onl"></div>
<?php include("../inc/foot.php");?>

</div>
</body>
</html>
<script language="javascript">
function $(id){
return document.getElementById(id);
}
function checkform(){
   if($("f_title").value==""){
      alert("放贷标题不能为空");
      $("f_title").focus();
      return false;
   }
   if($("f_jiner").value==""){
      alert("选择贷款金额");
      $("f_jiner").focus();
      return false;
   } 
   if($("f_duixiang").value==""){
      alert("选择贷款对象");
      $("f_duixiang").focus();
      return false;
   }      
   if($("f_zhouqi1").value==""){
      alert("贷款周期不能为空");
      $("f_zhouqi1").focus();
      return false;
   }
   if($("f_zhouqi2").value==""){
      alert("选择贷款周期参数");
      $("f_zhouqi2").focus();
      return false;
   }
   if($("f_lilv1").value==""){
      alert("贷款利率不能为空");
      $("f_lilv1").focus();
      return false;
   }
   if($("f_shenpi").value==""){
      alert("贷款审批时间不能为空");
      $("f_shenpi").focus();
      return false;
   }
   if($("c_provinces").value==""){
      alert("请选择省份");
      $("c_provinces").focus();
      return false;
   }
   if($("c_city").value==""){
      alert("请选择城市");
      $("c_city").focus();
      return false;
   }
  
   if($("f_danbao").value==""){
      alert("请选择地区");
      $("f_danbao").focus();
      return false;
   } 
   if($("f_danbao").value==""){
      alert("担保方式不能为空");
      $("f_danbao").focus();
      return false;
   }   
   if($("f_shuoming").value==""){
      alert("贷款说明不能为空");
      $("f_shuoming").focus();
      return false;
   }   
}
</script>